package net.wofly.common.util;

import net.wofly.common.persistence.PageWrapper;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * TODO<br/>
 * Copyright (c) 2014 , 北京可思云海科技有限公司<br/>
 * 2014-9-5 下午2:22:44
 * @author sqw@kscloud.com
 * @version V1.0
 */

public class PageHelper {
	
//	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static <T> PageWrapper<T> toPage(Page<T> page){
		return new PageWrapper<T>(page.getNumber(), page.getSize(), page.getTotalElements(), page.getTotalPages(), page.getContent());
	}
	
	public static <T> PageWrapper<T> toPage(Page<T> page ,List<T> contents){
		return new PageWrapper<T>(page.getNumber(), page.getSize(), page.getTotalElements(), page.getTotalPages(), contents);
	}
	
	public static <T> PageWrapper<T> toPage(int pageNumber ,int pageSize , Long totalElement, int totalPages ,List<T> contents){
		return new PageWrapper<T>(pageNumber, pageSize, totalElement, totalPages, contents);
	}
}
